package com.zdp.controller;

import com.zdp.HeadHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sesshomaru
 * @date 2021/7/19
 */
@RestController
public class StockController {

    @Autowired
    private HeadHelper headHelper;

    @GetMapping("/stock/reduce/{productId}")
    public String reduce(@PathVariable Integer productId) {
        System.out.println("请求头token: " + headHelper.getToken());
        System.out.println("商品" + productId + "扣减库存成功");
        if (productId > 3) {
            throw new RuntimeException("商品信息异常");
        }
        return "商品" + productId + "扣减库存成功";
    }
}
